package com.loren.service.impl;

import com.loren.config.DynamicDataSourceHolder;
import com.loren.constant.DataSourceContant;
import com.loren.entity.DbInfo;
import com.loren.repository.DbInfoRepository;
import com.loren.service.DbInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DbInfoServiceImpl implements DbInfoService {

    @Autowired
    private DbInfoRepository dbInfoRepository;

    @Override
    public DbInfo getDbInfoDetail() {
//        切换到默认的数据源
        DynamicDataSourceHolder.setDataSourceType(DataSourceContant.DEFAULT_DATASOURCE);
        return this.dbInfoRepository.findById(1).orElse(null);
    }
}
